package cn.android.x.parent;

import android.os.Bundle;
import android.view.View;

import com.gyf.immersionbar.ImmersionBar;
import com.sinothk.widget.loadingRecyclerView.LoadingRecyclerView;
import com.sinothk.widget.loadingRecyclerView.ProgressStyle;

import cn.android.x.R;
import cn.sinothk.hussars.views.LoadRecycleViewBaseActivity;

public abstract class AppRecycleViewTitleBaseActivity<T> extends LoadRecycleViewBaseActivity<T> {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutResId());
        ImmersionBar.with(this)
                .statusBarDarkFont(true).init();
    }

    protected abstract int getLayoutResId();

    @Override
    public void setViewTitle(String centerTxt) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterTxtColor(R.color.page_title);
    }

    public void setViewTitle(String centerTxt, String rightTxt, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterTxtColor(R.color.page_title);

        titleBarView.setRight1Txt(rightTxt, clickListener);
        titleBarView.setRight1TxtColor(R.color.page_title);
    }

    @Override
    protected void initRecycleLinearView(LoadingRecyclerView recyclerView) {
        super.initRecycleLinearView(recyclerView);
        // 设置刷新样式
        recyclerView.setRefreshProgressStyle(ProgressStyle.BallZigZag);
        recyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallZigZag);
    }

    @Override
    protected int getLineDrawable() {
        return R.drawable.list_divider;
    }
}
